<template>
  <div>
    <el-table :data="lst1">
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="title" label="标题"> </el-table-column>
      <el-table-column prop="price" label="价格"> </el-table-column>
      <el-table-column prop="userid" label="卖家"> </el-table-column>
      <el-table-column prop="" label="购买">
        <template slot-scope="scope">
        <el-button type="text" size="small" @click="handleClick(scope.row.id)">加入购物车</el-button>
      </template>
         </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
    data(){
        return{
            lst1:"",
            userid:localStorage.getItem("userid")
        }
    },
    mounted(){
        this.getgoods()
    },
    methods:{
        getgoods(){
            this.axios.get("/getgoods").then(res =>{
                this.lst1 = res.data.data
            })
        },
        handleClick(id){
            this.axios.get("/setgwc?userid="+this.userid+"&goodsid="+id).then(res =>{
                alert(res.data.msg)
            })
        },
        
    }
}
</script>

<style>

</style>